<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="">

    <link rel="shortcut icon" href="<!--{eval echo register_static('img/touch-icon-57x57.png');}-->">

    <title>粉粉管理系统</title>

    <!-- Bootstrap core CSS -->
    <link href="<!--{eval echo register_static('css/bootstrap.min.css');}-->" rel="stylesheet">
    <link href="<!--{eval echo register_static('css/bootstrap-reset.css');}-->" rel="stylesheet">

    <!--Animation css-->
    <link href="<!--{eval echo register_static('css/animate.css');}-->" rel="stylesheet">

    <!--Icon-fonts css-->
    <link href="<!--{eval echo register_static('assets/font-awesome/css/font-awesome.css');}-->" rel="stylesheet" />
    <link href="<!--{eval echo register_static('assets/ionicon/css/ionicons.min.css');}-->" rel="stylesheet" />

    <link href="<!--{eval echo register_static('assets/sweet-alert/sweet-alert.min.css');}-->" rel="stylesheet">

    <!-- Plugins css -->
    <link href="<!--{eval echo register_static('assets/modal-effect/css/component.css');}-->" rel="stylesheet">

    <!-- DataTables -->
    <link rel="stylesheet" href="<!--{eval echo register_static('assets/datatables/jquery.dataTables.min.css" rel="stylesheet');}-->" />

    <!-- Custom styles for this template -->
    <link href="<!--{eval echo register_static('css/style.css');}-->" rel="stylesheet">
    <link href="<!--{eval echo register_static('css/helper.css');}-->" rel="stylesheet">

    <!-- My styles for this template -->
    <link href="<!--{eval echo register_static('css/common.css');}-->" rel="stylesheet">
    <link href="<!--{eval echo register_static('assets/timepicker/bootstrap-timepicker.min.css');}-->" rel="stylesheet">
    <link href="<!--{eval echo register_static('assets/timepicker/bootstrap-datepicker.min.css');}-->" rel="stylesheet">

</head>

<body id="mybody">

<!-- Aside Start-->
<!--{template admin_v2/leftside}-->
<!-- Aside Ends-->


<!--Main Content Start -->
<section class="content">

    <!-- Header -->
    <!--{template admin_v2/header}-->
    <!-- Header Ends -->


    <!-- Page Content Start -->
    <!-- ================== -->

    <div class="wraper container-fluid diary-topics">

        <div class="row">
            <div class="col-md-12">
                <div class="panel panel-default">
                    <div class="panel-heading">
                        <h3 class="panel-title">客户端日志列表</h3>
                    </div>
                    <div class="panel-body">
                        <div class="row" style="margin-bottom: 10px">
                            <div class="col-md-11 col-sm-11 col-xs-11">
                                <!-- Search -->
                                <div class="form-inline">
                                    <div class="form-group pageCon">

                                    </div>
                                </div>
                            </div>
                            <div class="col-md-1 col-sm-1 col-xs-1">
                                <button class="btn btn-info myAdd"><i class="ion-search"></i> 搜索用户</button>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-12 col-sm-12 col-xs-12">
                                <table id="datatable" class="table table-striped table-bordered table-hover">
                                    <thead>
                                    <tr>
                                        <th>id</th>
                                        <th>uid</th>
                                        <th>类型</th>
                                        <th>客户端信息</th>
                                        <th>日志</th>
                                        <th>时间</th>
                                        <th>处理进度</th>
                                        <th>操作</th>
                                    </tr>
                                    </thead>

                                    <tbody id="tbody">

                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

    </div>
    <!-- Page Content Ends -->
    <!-- ================== -->

    <div id="con-close-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;">

    </div><!-- /.modal -->


    <!-- Footer Start -->
    <!--{template admin_v2/footer}-->
    <!-- Footer Ends -->



</section>
<!-- Main Content Ends -->

<!--template start-->
<script type="text/template" id="tableCon">
    {{#.}}
    <tr>
        <td>{{{id}}}</td>
        <td><label class="label label-success">{{{uid}}}</label></td>
        <td><span style="color: #df8505">{{{type}}}</span></td>
        <td><span style="color: #df8505">{{{client}}}</span></td>
        <td><a type="button" class="btn btn-info" href="{{{logpath}}}" target="_blank">下载</a></td>
        <td><label class="label label-info">{{{dateConv create_at}}}</label></td>
        <td>
            <div class="form-group">
                <select class="form-control myRate" style="width: 100px" name="rate" data-id="{{{id}}}">
                    {{{clientRateSelect rate}}}
                </select>
            </div>
        </td>
        <td>
            <div class="btn-group btn-group-sm">
                <button type="button" class="btn btn-danger myDelete" data-id="{{{id}}}">删除</button>
            </div>
        </td>
    </tr>
    {{/.}}
</script>
<!-- 新增推荐用户 -->
<script type="text/template" id="addModal">
    <form>
        <div>
            <table class="table table-bordered">
                <thead>
                <tr>
                    <th width="25%">类别</th>
                    <th width="75%">内容</th>
                </tr>
                </thead>
                <tbody>
                <tr>
                    <td>UID</td>
                    <td >
                        <div class="form-inline">
                            <div class="form-group">
                                <input type="text" name="uid" class="form-control"  placeholder="" value="" style="width: 170px">
                            </div>
                        </div>
                    </td>
                </tr>
                <tr>
                    <td>操作</td>
                    <td style="text-align: center">
                        <button type="button" class="btn btn-info myFindUid">查找</button>
                    </td>
                </tr>
                </tbody>
            </table>
        </div>
    </form>
</script>
<script type="text/template" id="mySortModal">
    <form>
        <div>
            <table class="table table-bordered">
                <thead>
                <tr>
                    <th width="25%">类别</th>
                    <th width="75%">内容</th>
                </tr>
                </thead>
                <tbody>
                <tr>
                    <td>排序序号</td>
                    <td >
                        <div class="form-inline">
                            <div class="form-group">
                                <input type="number" name="sort" class="form-control"  placeholder="" value="{{{sort}}}" style="width: 170px">
                                <input type="hidden" name="id" value="{{{id}}}">
                            </div>
                        </div>
                    </td>
                </tr>
                <tr>
                    <td>操作</td>
                    <td style="text-align: center">
                        <button type="button" class="btn btn-info mySortPost">确定</button>
                    </td>
                </tr>
                </tbody>
            </table>
        </div>
    </form>
</script>
<!--template end-->


<!-- js placed at the end of the document so the pages load faster -->
<script src="<!--{eval echo register_static('js/jquery.js');}-->"></script>
<script src="<!--{eval echo register_static('js/bootstrap.min.js');}-->"></script>
<script src="<!--{eval echo register_static('js/pace.min.js');}-->"></script>
<script src="<!--{eval echo register_static('js/wow.min.js');}-->"></script>
<script src="<!--{eval echo register_static('js/jquery.nicescroll.js');}-->" type="text/javascript"></script>
<script src="<!--{eval echo register_static('js/jquery.app.js');}-->"></script>

<script src="<!--{eval echo register_static('js/handlebars-v4.0.5.js');}-->"></script>
<script src="<!--{eval echo register_static('js/handlebars-helper.js');}-->"></script>
<script src="<!--{eval echo register_static('layer/layer.js');}-->"></script>
<script src="<!--{eval echo register_static('laypage/laypage.js');}-->"></script>
<script src="<!--{eval echo register_static('laydate/laydate.js');}-->"></script>

<script src="<!--{eval echo register_static('assets/datatables/jquery.dataTables.min.js');}-->"></script>
<script src="<!--{eval echo register_static('assets/datatables/dataTables.bootstrap.js');}-->"></script>
<script src="<!--{eval echo register_static('assets/sweet-alert/sweet-alert.min.js');}-->"></script>
<script src="<!--{eval echo register_static('assets/sweet-alert/sweet-alert.init.js');}-->"></script>

<!-- Modal-Effect -->
<script src="<!--{eval echo register_static('assets/modal-effect/js/classie.js');}-->"></script>
<script src="<!--{eval echo register_static('assets/modal-effect/js/modalEffects.js');}-->"></script>

<script type="text/javascript">
    $(document).ready(function() {

        //编译模板
        var tp_tableCon = Handlebars.compile($('#tableCon').html());
        var tp_addModal = Handlebars.compile($('#addModal').html());
        var tp_mySortModal = Handlebars.compile($('#mySortModal').html());

        $(document).off('change', '.myRate').on('change', '.myRate', function () {
            var rate = $(this).val();
            var id = $(this).data('id');
            layer.load();
            $.post(
                    '/admin.php?ac=recommentlist&op=logedit',
                    {id:id, rate:rate},
                    function (r) {
                        layer.closeAll();
                        r._code==1 ? layer.msg('id:'+id+' 已调整进度至'+rate+'%', {icon: 1}) : layer.msg('操作失败', {icon: 0});
                    }
            );
        });

        //添加用户
        $('.myAdd').click(function () {
            var html = tp_addModal();
            layer.open({
                type: 1,
                title: '搜索用户日志',
                closeBtn: 1,
                area:['320px', '250px'],
                shadeClose: true,
                content: html
            });
        });
        //调整排序
        $(document).off('click', '.mySort').on('click', '.mySort', function () {
            var data = {
                id:$(this).data('id'),
                sort:$(this).data('sort')
            }
            var html = tp_mySortModal(data);
            layer.open({
                type: 1,
                title: '编辑排序',
                closeBtn: 1,
                area:['320px', '210px'],
                shadeClose: true,
                content: html
            });
        });
        //执行查找
        $(document).off('click', '.myFindUid').on('click', '.myFindUid', function () {
            var uid = $(this).parents('form').find('input[name="uid"]').val();
            if (!uid)return ;
            layer.closeAll();
            _Where_.uid = uid;
            _Where_.page = 1;
            RequestList();
        });

        //删除用户
        $(document).off('click', '.myDelete').on('click', '.myDelete', function () {
            var id = $(this).data('id');
            if (!id)return;
            layer.confirm('确定删除id '+ id +' ？', {icon: 3, title:'提示'}, function(i){
                var index = layer.load();
                $.post(
                        '/admin.php?ac=recommentlist&op=logdel&id=' + id,
                        function (r) {
                            layer.close(index);
                            if(r._code == 1){
                                layer.closeAll();
                                RequestList();
                                layer.msg('已删除', {icon: 1});
                            }else{
                                layer.msg(r._msg, {icon: 0});
                            }
                        }
                );
            });
        });

        _Where_ = {page:1};
        //请求数据列表数据
        var RequestList = function () {
            where = _Where_;
            if(typeof where == 'undefined')where = {};
            var index = layer.load();
            $.post(
                    '/admin.php?ac=recommentlist&op=loglist',
                    where,
                    function (r) {
                        if (r._code == 1){
                            var html = tp_tableCon(r.result);
                            $('#tbody').html(html);
                            laypage({
                                cont: $('.pageCon'), //容器。值支持id名、原生dom对象，jquery对象。【如该容器为】：<div id="page1"></div>
                                pages: 100, //通过后台拿到的总页数
                                curr: _Where_.page || 1, //当前页
                                jump: function(obj, first){ //触发分页后的回调
                                    if(!first){ //点击跳页触发函数自身，并传递当前页：obj.curr
                                        _Where_.page = obj.curr;
                                        RequestList();
                                    }
                                }
                            });
                        }else{
                            layer.msg(r._msg, {icon: 0});
                        }
                        layer.close(index);
                    }
            );
        }
        RequestList();

    } );
</script>
</body>
</html>
